package net.suncaper.psychological.service.impl;

import net.suncaper.psychological.mapper.CaseReportMapper;
import net.suncaper.psychological.mapper.impl.CaseReportMapperImpl;
import net.suncaper.psychological.model.domain.CaseReport;
import net.suncaper.psychological.service.ICaseReportService;

import java.util.List;

public class CaseReportServiceImpl implements ICaseReportService {
    
    private final CaseReportMapper caseReportMapper = new CaseReportMapperImpl();
    
    @Override
    public boolean createCaseReport(CaseReport caseReport) {
        try {
            return caseReportMapper.insert(caseReport) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    
    @Override
    public CaseReport getCaseReportByAppointmentId(Long appointmentId) {
        try {
            return caseReportMapper.findByAppointmentId(appointmentId);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    
    @Override
    public List<CaseReport> getCaseReportsByStudentId(Long studentId) {
        try {
            return caseReportMapper.findByStudentId(studentId);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    
    @Override
    public List<CaseReport> getCaseReportsByConsultantId(Long consultantId) {
        try {
            return caseReportMapper.findByConsultantId(consultantId);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    
    @Override
    public boolean updateCaseReport(CaseReport caseReport) {
        try {
            return caseReportMapper.update(caseReport) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    
    @Override
    public boolean deleteCaseReport(Long id) {
        try {
            return caseReportMapper.deleteById(id) > 0;
        } catch (Exception e) {
            e.printStackTrace();
            return false;
        }
    }
    
    @Override
    public List<CaseReport> getAllCaseReports() {
        try {
            return caseReportMapper.findAll();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
} 